<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of HomePage
 *
 * @author juwking
 */
class ClientPage extends PageController {

    function __construct() {
        parent::__construct();
    }

    function getPageName() {
        return 'client';
    }

    function defaultAction() {
        $this->smarty->display('client/client.tpl');
    }

    public function showClientGrid() {
        include_once '../components/DataGrid/clientforshow.php';
    }

    public function generateClients() {
        $nameArray = array();
        $myfile = '../names';
        $lines = file($myfile);
        $max = count($lines);
        for ($i = $max; $i > 0; $i--) {
            $nameArray[] = trim($lines[$i]);
        }
        $max = count($nameArray);
        $start = getTime();
        for ($i = 0; $i < 1800; ++$i) {
            $client = new Client();
            $client->setName($nameArray[rand(1, $max)]);
            $client->setSurname($nameArray[rand(1, $max)]);
            $client->setEmail($nameArray[rand(1, $max)] . '@' . $nameArray[rand(1, $max)] . '.com');
            $client->setAge(rand(12, 80));
            $post = array('a', 'e', 'i');
            if (in_array(substr($client->getName(), -1), $post)) {
                $client->setGender(1);
            }
            else
                $client->setGender(0);
            $client->setClientCategoriesId(1);
            $client->save();
        }
        $end = getTime();
        echo 'Done in ' . ($end - $start);
    }

}

?>
